Skip settings schema validation on PowerShell versions less than 7#2231
Skip settings schema validation on PowerShell versions less than 7#2231Copilot wants to merge 14 commits into
Conversation
Write settings JSON to a temp file instead of passing it as a command-line argument to pwsh.exe, which exceeds the Windows command-line length limit (~32K chars) for large settings. Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/90f81e6b-6fa6-4fa5-9a16-4c43637c704d Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…th limit Instead of writing to a temp file, simply skip the validation when the settings JSON is too large (>30K chars) for the Windows command-line limit. Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/333f25d2-8e08-4ebf-8b95-fc6fe2001579 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/8ee7b1e9-d14b-41b8-b172-81c61ffe05c8 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a Windows PowerShell 5.1 limitation where ValidateSettings shells out to pwsh and can exceed the Windows ~32K command-line length limit when passing large settings JSON, causing validation to fail.
Changes:
- Add a PS5.1 guard to skip settings schema validation when the serialized settings JSON is larger than 30,000 characters.
- Update release notes to document the fix for the “filename or extension is too long” validation error.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| RELEASENOTES.md | Documents the PS5.1 validation-length-limit fix in the Issues list. |
| Actions/.Modules/ReadSettings.psm1 | Adds an early-exit condition in ValidateSettings for PS5.1 when settings JSON is very large. |
|
@copilot apply changes based on the comments in this thread |
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/2daf92be-f2f4-44c9-a10c-46a1bd01e4c9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Applied all three changes from the review in commit bb500e1:
|
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/a56d8a43-8737-4e44-a8d7-e0b0370497b9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…s test Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/a6d20e17-ae77-432d-92ee-c96d102e2301 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
…versized JSON Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/60d8dbf0-a9a5-4827-9ba8-7459f8bd422a Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
The test should assert on OutputWarning (the function ValidateSettings actually calls) rather than Write-Host (an internal implementation detail of DebugLogHelper). Also removes unnecessary Out-Host mock. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
|
@copilot Actually, let's skip the validation altogether if the PS version is less than 7. |
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/73ceb4f7-4660-47fa-818e-8b464addd475 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Done in d3d942c — validation is now skipped entirely when |
…unction Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/9e9cfcd2-5c9d-442a-aa5b-5814047ed25d Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
| else { | ||
| $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile | ||
| } | ||
| $result = Invoke-Command -ScriptBlock $command -ArgumentList $settingsJson, $settingsSchemaFile |
Agent-Logs-Url: https://github.com/microsoft/AL-Go/sessions/d00cb97b-e021-433d-8b52-e273feee35d9 Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
❔What, Why & How
On PS5.1,
ValidateSettingsshells out topwsh.exepassing the full settings JSON as a command-line argument. For repositories with many projects/settings, the JSON can exceed the ~32K Windows command-line limit, producing:Fix: Silently skip schema validation entirely when
$PSVersionTable.PSVersion.Major -lt 7. TheValidateSettingsfunction now performs a hardreturnat the very beginning of itsProcessblock on PS < 7, avoiding any JSON serialization orpwshinvocation. On PS7+,Test-Jsonis called directly (the previousInvoke-Commandwrapper has been removed since it's no longer needed with the early exit guard).✅ Checklist